<?php

/**
 * model_subject
 */

class Model_subject extends YOU {

	public function __construct()
	{
		parent::__construct();
	}

	/** 读取成配置 **/
	public function getIni()
	{
		$subject_lists = $this->getAll();
		foreach ($subject_lists as $key => $value){
			$subject[$value['subject_id']] = $value['subject_name'];
		}

		return $subject;
	}

	/** 读取列表 **/
	public function getAll($field = "*")
	{
		$subject_lists = $this->db->fetchAll("SELECT {$field} FROM `tbl_subject` ");

		return $subject_lists;
	}

	/** 读取信息 **/
	public function getInfo($subject_id, $field = "*")
	{
		$data = $this->db->fetchRow("SELECT {$field} FROM `tbl_subject` WHERE subject_id='{$subject_id}' ");

		return $data;
	}

	/** 读取名称根据id **/
	public function getNameById($subject_id)
	{
		$data = $this->getInfo($subject_id, "subject_name");

		return $data['subject_name'];
	}
	/** 读取年级科目信息 **/
	public function getgradeInfo($grade_id, $field = "*")
	{
		$data = $this->db->fetchAll("SELECT {$field} FROM `tbl_grade_subject` WHERE grade_id='{$grade_id}' ");

		return $data;
	}

}



?>